home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2001 September / PC-WELT 9-2001.ISO / software / hw / brennen / flask_src.exe / Audio / AC3 / AC3Dec / stats.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-06  |  5.4 KB  |  178 lines

  1. /* 
  2.  *  stats.c
  3.  *
  4.  *    Copyright (C) Aaron Holtzman - May 1999
  5.  *
  6.  *  This file is part of ac3dec, a free Dolby AC-3 stream decoder.
  7.  *    
  8.  *  ac3dec is free software; you can redistribute it and/or modify
  9.  *  it under the terms of the GNU General Public License as published by
  10.  *  the Free Software Foundation; either version 2, or (at your option)
  11.  *  any later version.
  12.  *   
  13.  *  ac3dec is distributed in the hope that it will be useful,
  14.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  *  GNU General Public License for more details.
  17.  *   
  18.  *  You should have received a copy of the GNU General Public License
  19.  *  along with GNU Make; see the file COPYING.  If not, write to
  20.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  21.  *
  22.  */
  23.  
  24. #include <stdlib.h>
  25. #include <stdio.h>
  26. #include "ac3.h"
  27. #include "ac3_internal.h"
  28.  
  29.  
  30. #include "decode.h"
  31. #include "stats.h"
  32. #include "debug.h"
  33.  
  34.  
  35. static const char *service_ids[8] = 
  36. {
  37.     "CM","ME","VI","HI",
  38.      "D", "C","E", "VO"
  39. };
  40.  
  41. struct mixlev_s
  42. {
  43.     float clev;
  44.     char *desc;
  45. };
  46.  
  47. static const struct mixlev_s cmixlev_tbl[4] =  
  48. {
  49.     {0.707, "(-3.0 dB)"}, {0.595, "(-4.5 dB)"},
  50.     {0.500, "(-6.0 dB)"}, {1.0,  "Invalid"}
  51. };
  52.  
  53. static const struct mixlev_s smixlev_tbl[4] =  
  54. {
  55.     {0.707, "(-3.0 dB)"}, {0.500, "(-6.0 dB)"},
  56.     {  0.0,   "off    "}, {  1.0, "Invalid"}
  57. };
  58.  
  59. static const char *language[128] = 
  60. {
  61.     "unknown", "Albanian", "Breton", "Catalan", "Croatian", "Welsh", "Czech", "Danish", 
  62.     "German", "English", "Spanish", "Esperanto", "Estonian", "Basque", "Faroese", "French", 
  63.     "Frisian", "Irish", "Gaelic", "Galician", "Icelandic", "Italian", "Lappish", "Latin", 
  64.     "Latvian", "Luxembourgian", "Lithuanian", "Hungarian", "Maltese", "Dutch", "Norwegian", "Occitan", 
  65.     "Polish", "Portugese", "Romanian", "Romansh", "Serbian", "Slovak", "Slovene", "Finnish", 
  66.     "Swedish", "Turkish", "Flemish", "Walloon", "0x2c", "0x2d", "0x2e", "0x2f", 
  67.     "0x30", "0x31", "0x32", "0x33", "0x34", "0x35", "0x36", "0x37", 
  68.     "0x38", "0x39", "0x3a", "0x3b", "0x3c", "0x3d", "0x3e", "0x3f", 
  69.     "background", "0x41", "0x42", "0x43", "0x44", "Zulu", "Vietnamese", "Uzbek", 
  70.     "Urdu", "Ukrainian", "Thai", "Telugu", "Tatar", "Tamil", "Tadzhik", "Swahili", 
  71.     "Sranan Tongo", "Somali", "Sinhalese", "Shona", "Serbo-Croat", "Ruthenian", "Russian", "Quechua", 
  72.     "Pustu", "Punjabi", "Persian", "Papamiento", "Oriya", "Nepali", "Ndebele", "Marathi", 
  73.     "Moldavian", "Malaysian", "Malagasay", "Macedonian", "Laotian", "Korean", "Khmer", "Kazakh",
  74.     "Kannada", "Japanese", "Indonesian", "Hindi", "Hebrew", "Hausa", "Gurani", "Gujurati", 
  75.     "Greek", "Georgian", "Fulani", "Dari", "Churash", "Chinese", "Burmese", "Bulgarian", 
  76.     "Bengali", "Belorussian", "Bambora", "Azerbijani", "Assamese", "Armenian", "Arabic", "Amharic"
  77. };
  78.  
  79. void stats_print_banner(syncinfo_t *syncinfo,bsi_t *bsi)
  80. {
  81. //    fprintf(stdout,PACKAGE"-"VERSION" (C) 2000 Aaron Holtzman (aholtzma@ess.engr.uvic.ca)\n");
  82.  
  83.     fprintf(stdout,"%d.%d Mode ",bsi->nfchans,bsi->lfeon);
  84.     fprintf(stdout,"%2.1f KHz",syncinfo->sampling_rate * 1e-3);
  85.     fprintf(stdout,"%4d kbps ",syncinfo->bit_rate);
  86.     if (bsi->langcode && (bsi->langcod < 128))
  87.         fprintf(stdout,"%s ", language[bsi->langcod]);
  88.  
  89.     switch(bsi->bsmod)
  90.     {
  91.         case 0:
  92.             fprintf(stdout,"Complete Main Audio Service");
  93.             break;
  94.         case 1:
  95.             fprintf(stdout,"Music and Effects Audio Service");
  96.         case 2:
  97.             fprintf(stdout,"Visually Impaired Audio Service");
  98.             break;
  99.         case 3:
  100.             fprintf(stdout,"Hearing Impaired Audio Service");
  101.             break;
  102.         case 4:
  103.             fprintf(stdout,"Dialogue Audio Service");
  104.             break;
  105.         case 5:
  106.             fprintf(stdout,"Commentary Audio Service");
  107.             break;
  108.         case 6:
  109.             fprintf(stdout,"Emergency Audio Service");
  110.             break;
  111.         case 7:
  112.             fprintf(stdout,"Voice Over Audio Service");
  113.             break;
  114.     }
  115.     fprintf(stdout,"\n");
  116. }
  117.  
  118. void stats_print_syncinfo(syncinfo_t *syncinfo)
  119. {
  120.     dprintf("(syncinfo) ");
  121.     
  122.     switch (syncinfo->fscod)
  123.     {
  124.         case 2:
  125.             dprintf("32 KHz   ");
  126.             break;
  127.         case 1:
  128.             dprintf("44.1 KHz ");
  129.             break;
  130.         case 0:
  131.             dprintf("48 KHz   ");
  132.             break;
  133.         default:
  134.             dprintf("Invalid sampling rate ");
  135.             break;
  136.     }
  137.  
  138.     dprintf("%4d kbps %4d words per frame\n",syncinfo->bit_rate, 
  139.             syncinfo->frame_size);
  140.  
  141. }
  142.     
  143. void stats_print_bsi(bsi_t *bsi)
  144. {
  145.     dprintf("(bsi) ");
  146.     dprintf("%s",service_ids[bsi->bsmod]);
  147.     dprintf(" %d.%d Mode ",bsi->nfchans,bsi->lfeon);
  148.     if ((bsi->acmod & 0x1) && (bsi->acmod != 0x1))
  149.         dprintf(" Centre Mix Level %s ",cmixlev_tbl[bsi->cmixlev].desc);
  150.     if (bsi->acmod & 0x4)
  151.         dprintf(" Sur Mix Level %s ",smixlev_tbl[bsi->cmixlev].desc);
  152.     dprintf("\n");
  153.  
  154. }
  155.  
  156. char *exp_strat_tbl[4] = {"R   ","D15 ","D25 ","D45 "};
  157.  
  158. void stats_print_audblk(bsi_t *bsi,audblk_t *audblk)
  159. {
  160.     uint_32 i;
  161.  
  162.     dprintf("(audblk) ");
  163.     dprintf("%s ",audblk->cplinu ? "cpl on " : "cpl off");
  164.     dprintf("%s ",audblk->baie? "bai " : "    ");
  165.     dprintf("%s ",audblk->snroffste? "snroffst " : "         ");
  166.     dprintf("%s ",audblk->deltbaie? "deltba " : "       ");
  167.     dprintf("%s ",audblk->phsflginu? "phsflg " : "       ");
  168.     dprintf("(%s %s %s %s %s) ",exp_strat_tbl[audblk->chexpstr[0]],
  169.         exp_strat_tbl[audblk->chexpstr[1]],exp_strat_tbl[audblk->chexpstr[2]],
  170.         exp_strat_tbl[audblk->chexpstr[3]],exp_strat_tbl[audblk->chexpstr[4]]);
  171.     dprintf("[");
  172.     for(i=0;i<bsi->nfchans;i++)
  173.         dprintf("%1d",audblk->blksw[i]);
  174.     dprintf("]");
  175.  
  176.     dprintf("\n");
  177. }
  178.